const fs=require('fs');
const path=require('path');
const argv=process.argv;

var delPath=path.join(__dirname,'/'+argv[2]);

function delFile(delPath){
    var fileObj=fs.statSync(delPath);
    if(fileObj.isFile()){
        fs.unlinkSync(delPath);
    }else{
        var fileArray=fs.readdirSync(delPath);
        for(var item of fileArray){
            childPath=path.join(delPath,'/'+item);
            delFile(childPath);
        }
        fs.rmdirSync(delPath);
    }
}
fs.access(delPath,(err)=>{
    if(err){
        console.log("该文件不存在");
    }else{
        delFile(delPath);
    }
})